package com.example.hr.text_android.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.hr.text_android.R;
import com.example.hr.text_android.entity.Main3Model;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.permissions.Permission;

import java.util.List;


/**
 * Created by hr on 2017/7/31.
 */
public class FabuAdapter extends BaseQuickAdapter<LocalMedia, FabuHolder> {
    private List<LocalMedia> list;
    //    private List<Main3Model> list;
    private Context context;

    public FabuAdapter(Context context) {
        super(R.layout.griditem);
        this.context = context;
    }

    //    public FabuAdapter(@Nullable List<LocalMedia> data, Context context) {
//        super(R.layout.griditem, data);
//        this.list = data;
//        this.context = context;
//    }
    public void setList(List<LocalMedia> list) {
        this.list = list;
    }


    @Override
    protected void convert(FabuHolder helper, LocalMedia item) {
        if (list.size() == 0) {
            helper.setImageResource(R.id.imageView1, R.mipmap.ic_addpic);
        } else {
            Glide.with(context)
                    .load(item.getPath())
                    .into(helper.imageView);
        }
    }

//    @Override
//    protected void convert(FabuHolder helper, Main3Model item) {
////        helper.setImageResource(R.id.imageView1, R.mipmap.ic_addpic);
//        Glide.with(context)
//                    .load(item.getPath())
//                    .into(helper.imageView);
//    }

//    @Override
//    protected void convert(BaseViewHolder helper, LocalMedia item) {
//        if (list.size() == 0) {
//            helper.setImageResource(R.id.imageView1, R.mipmap.ic_addpic);
//        }else {
//            Glide.with(context)
//                    .load(item.getPath())
//                    .into();
//        }
//    }


}
